package com.mesnac.comm.servlet;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

import com.mesnac.comm.service.IService;
import com.mesnac.comm.service.InitService;
/**
 * 
* @ClassName: InitServlet
* @Description: 需要启动加载的servlet，完成配置信息的读取
* @author chilei chil07@mesnac.com
* @date Sep 5, 2012 2:35:22 PM
*
 */
public class InitServlet extends HttpServlet {
	
	private static IService initService;
	static{
		initService = new InitService();
	}

	
	@Override
	public void init() throws ServletException{
		try{
			
			initService.startService(getServletContext(), getServletConfig());
			
		}catch(ServletException e){
			e.printStackTrace();
			throw new ServletException();
		}catch(Exception e){
			e.printStackTrace();			
		}
		super.init();
	}
	
	@Override
	public void destroy(){
		try{
			initService.stopService(getServletContext(), getServletConfig());
		}catch(Exception e){
			e.printStackTrace();	
		}
		super.destroy();
	}

	public IService getInitService() {
		return initService;
	}

	public void setInitService(IService initService) {
		InitServlet.initService = initService;
	}
	

}
